<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>iWebPDF2018</title>
    <script src="../config/config.project.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        html,
        body {
            width: 100%;
            height: 100%;
        }

        .pdf-box {
            width: 100%;
            margin: 0 auto;
            height: 100%;
        }
    </style>
</head>

<body>
    <div class="pdf-box">
        <!-- 内容主体区域 -->
        <script type="text/javascript" src="./js/iWebPDF2018.js"></script>
    </div>
</body>
<script type="text/javascript" src="./js/PDF2018.js"></script>
<script>
    var base_url = localStorage.getItem("local_server_ip") || window.HC_config.VUE_APP_BASE_API;

    function getQueryObject(url)
    {
        url = url == null ? window.location.href : url
        const search = url.substring(url.lastIndexOf('?') + 1)
        const obj = {}
        const reg = /([^?&=]+)=([^?&=]*)/g
        search.replace(reg, function (rs, $1, $2)
        {
            const name = decodeURIComponent($1)
            var val = decodeURIComponent($2)
            val = String(val)
            obj[name] = val
            return rs
        })
        return obj
    }

    var urlParms = getQueryObject(window.location.href);
    var wordId = urlParms.wordId;
    var relationunid = urlParms.parentUnid;

    //谷歌下工具栏按钮触发事件
    function OnToolsClick(vIndex, vCaption)
    {
        //alert('编号:'+vIndex+'\n\r'+'条目:'+vCaption+'\n\r'+'请根据这些信息编写按钮具体功能');
        if (vIndex == 10)
        {
            var mResuld = iWebPDF2018.HttpClient.UpLoadToServer(base_url + "/jgqz/savePdfFile?relationunid=" + relationunid);
            iWebPDF2018.iWebPDFFun.alert("保存成功");
        }
    }


    function OnAddSignature(e)
    {
        console.log("-------添加签章事件-----------------")
        console.log(e)
        console.log("-------添加签章事件-----------------")

        var mResuld = iWebPDF2018.HttpClient.UpLoadToServer(base_url + "/jgqz/savePdfFile?relationunid=" + relationunid);
        console.log(mResuld)
    }

    function OnWebSaveAfter(e)
    {
        console.log("-------保存前事件----------")
        console.log(e);
        console.log("-------保存前事件----------")
    }

    function OnOpen(e)
    {
        console.log("-------打开文件成功----------")
        console.log(e);
        console.log("-------打开文件成功----------")
    }
    function OnWebOpenAfter(e)
    {
        console.log("-------打开文件前事件----------")
        console.log(e);
        console.log("-------打开文件前事件----------")
    }

    window.onload = function ()
    {
        //初始化插件
        load();
        EnableShowTools("0");
        addins.AppendTools("10", "保存文件", 1);
        // var  addins=iWebPDF2018.iWebPDFFun;

        //addins.USERNAME = "管理员";
        var ret = addins.WebOpenUrlFile(base_url + "/jgqz/download/" + wordId);
        console.log(ret)
        console.log(addins);
        if (!ret)
        {
            addins.Alert("文档打开失败！");
        }
        else
        {
            var singDataStr = "";
            if (singDataStr != "" && singDataStr)
            {
                //调用接口获取该文档签章,加载到文档中
                var isok = addins.LoadLocalSignData(singDataStr);
            }
        }

    }
</script>

</html>